import socket
server_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
server_socket.bind(("127.0.0.1",8888))
while True:
    server_socket.listen(5)
    conn,addr = server_socket.accept()
    print("ip:%s连接了您的服务器"%addr[0])
    while True:
        if conn:
            try:
                data = conn.recv(1024).decode("utf-8")
                print("服务器发来的消息:%s"%data)
                cmd = input(">>>")
                conn.send(cmd.encode("utf-8"))
                print("发送成功!!")
            except ConnectionResetError:
                print("客户端断开了链接!")
                break
    conn.close()
